// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/maintain/api/PlanTaskApi'

import SubmitClass from '@api/maintain/model/AddPlanTaskEventReq'
import EventClass from '@api/maintain/model/PlanTaskEventDto'

const CLIENT = CORE.grpcCLIENT(Client)

const EVENT = [EventClass, 'planTaskEventDto']

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 转派 —————————————————————————————— //

  async forward(one, TIP = '任务转派') {
    const DTO = CORE.grpcDTO(SubmitClass, one, EVENT)
    await CORE.grpc(TIP, CLIENT, 'forwardTask', DTO)
    return CORE.grpcOK(TIP)
  },

  // —————————————————————————————— 审核 —————————————————————————————— //

  async review(one, TIP = '任务审核') {
    const DTO = CORE.grpcDTO(SubmitClass, one, EVENT)
    await CORE.grpc(TIP, CLIENT, 'reviewTask', DTO)
    return CORE.grpcOK(TIP)
  },

  // —————————————————————————————— 撤销 —————————————————————————————— //

  async cancel(one, TIP = '任务撤销') {
    const DTO = CORE.grpcDTO(SubmitClass, one, EVENT)
    await CORE.grpc(TIP, CLIENT, 'cancelTask', DTO)
    return CORE.grpcOK(TIP)
  },
}
